package com.leyou.item.mapper;

import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 *
 *
 *
 *
 * create by Rose on 2020/1/8
 */

public interface BrandMapper extends BaseMapper<Brand, Long> {


    /**
     *  新增商品分类和品牌中间表的数据
     * @param cid 商品分类id
     * @param id  品牌id
     */
    @Insert("insert into tb_category_brand (category_id, brand_id) values ( #{cid}, #{bid} )")
    int insertCategoryBrand(@Param("cid") Long cid, @Param("bid") Long id);


    @Delete("delete from tb_category_brand where brand_id = #{cid} ")
    int deleteCategoryBrand(@Param("cid") Long cid);

    @Select(value = " select b.* from tb_category_brand cb inner join tb_brand b on b.id = cb.brand_id where cb.category_id = #{cid} ")
    List<Brand> queryByCategoryId(@Param("cid") Long cid);


}
